﻿using System.Collections.Generic;
using System.Configuration;

namespace TestStarter.Util
{
    public class ApplicationSettings
    {
        private static readonly string URL = "url";
        private static readonly string FOLDER = "test_folder";

        public static string SERVER_URL = ConfigurationManager.AppSettings[URL];
        public static string SCAN_FOLDER = ConfigurationManager.AppSettings[FOLDER];

        public ApplicationSettings()
        {

        }

        public static IList<string> UpdateValues(string url, string folderPath)
        {
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            config.AppSettings.Settings[ApplicationSettings.URL].Value = url;
            config.AppSettings.Settings[ApplicationSettings.FOLDER].Value = folderPath;

            ApplicationSettings.SERVER_URL = url;
            ApplicationSettings.SCAN_FOLDER = folderPath;

            config.Save(ConfigurationSaveMode.Modified);
            ConfigurationManager.RefreshSection("appSettings");

            return ValidateUtility.ValidateSettings(url, folderPath);
        }

    }
}
